﻿CREATE TABLE [dbo].[Import_Persoane] (
    [IdPersoana]            INT              IDENTITY (1, 1) NOT NULL,
    [NumePrenume]           VARCHAR (150)    NOT NULL,
    [Nume_Anterior]         VARCHAR (50)     NULL,
    [Cnp]                   DECIMAL (13)     NOT NULL,
    [Sex]                   SMALLINT         CONSTRAINT [DF_IMPORT_PERSOANE_Sex] DEFAULT ((0)) NOT NULL,
    [DataNasterii]          DATETIME         NOT NULL,
    [IDLocNastere]          INT              NOT NULL,
    [TipAI]                 SMALLINT         DEFAULT ((0)) NOT NULL,
    [SeriaAI]               VARCHAR (3)      NOT NULL,
    [NumarAI]               VARCHAR (15)     NOT NULL,
    [DataElibAI]            DATETIME         NOT NULL,
    [EmitentAI]             VARCHAR (100)    NOT NULL,
    [NumeTata]              VARCHAR (50)     NULL,
    [NumeMama]              VARCHAR (50)     NULL,
    [StradaAdr]             VARCHAR (100)    NOT NULL,
    [IDLocalitateAdr]       INT              NOT NULL,
    [NrAdr]                 VARCHAR (10)     NOT NULL,
    [BlocAdr]               VARCHAR (10)     NOT NULL,
    [EtajAdr]               VARCHAR (10)     NULL,
    [ScaraAdr]              VARCHAR (10)     NULL,
    [ApartamentAdr]         VARCHAR (10)     NOT NULL,
    [GradInvaliditate]      SMALLINT         NULL,
    [TelefonFix]            VARCHAR (20)     NULL,
    [TelefonMobil]          VARCHAR (20)     NOT NULL,
    [Observatii]            VARCHAR (100)    NULL,
    [NumarCM]               VARCHAR (10)     CONSTRAINT [DF_IMPORT_PERSOANE_NumarCM] DEFAULT ('') NOT NULL,
    [SerieCM]               VARCHAR (10)     CONSTRAINT [DF_IMPORT_PERSOANE_SerieCM] DEFAULT ('') NOT NULL,
    [CodUnitate]            SMALLINT         CONSTRAINT [DF_IMPORT_PERSOANE_CodUnitate] DEFAULT ((0)) NOT NULL,
    [NrFileCM]              SMALLINT         CONSTRAINT [DF_IMPORT_PERSOANE_NrFileCM] DEFAULT ((0)) NOT NULL,
    [NrCutieCM]             VARCHAR (10)     CONSTRAINT [DF_IMPORT_PERSOANE_NrCutieCM] DEFAULT ('') NOT NULL,
    [Marca]                 VARCHAR (20)     CONSTRAINT [DF_IMPORT_PERSOANE_Marca] DEFAULT ('FARA') NOT NULL,
    [TelefonInterior]       VARCHAR (20)     NULL,
    [IdCasaAsigSanatate]    SMALLINT         CONSTRAINT [DF_IMPORT_PERSOANE_IdCasaAsigSanatate] DEFAULT ((0)) NOT NULL,
    [IdTipStudii]           INT              CONSTRAINT [DF_IMPORT_PERSOANE_IdTipStudii] DEFAULT ((0)) NOT NULL,
    [DataVechimeMunca]      DATETIME         CONSTRAINT [DF_IMPORT_PERSOANE_DataVechimeMunca] DEFAULT (getdate()) NOT NULL,
    [UserID]                UNIQUEIDENTIFIER NULL,
    [PozCutieCM]            SMALLINT         CONSTRAINT [DF_IMPORT_PERSOANE_PozCutieCM] DEFAULT ((0)) NOT NULL,
    [PlatesteCAS]           BIT              CONSTRAINT [DF_IMPORT_PERSOANE_PlatesteCAS] DEFAULT ((1)) NOT NULL,
    [PlatesteCASS]          BIT              CONSTRAINT [DF_IMPORT_PERSOANE_PlatesteCASS] DEFAULT ((1)) NOT NULL,
    [PlatesteSomaj]         BIT              CONSTRAINT [DF_IMPORT_PERSOANE_PlatesteSomaj] DEFAULT ((1)) NOT NULL,
    [PlatesteImpozit]       BIT              CONSTRAINT [DF_IMPORT_PERSOANE_PlatesteImpozit] DEFAULT ((1)) NOT NULL,
    [AreDeducere]           BIT              CONSTRAINT [DF_IMPORT_PERSOANE_AreDeducere] DEFAULT ((1)) NOT NULL,
    [DataPlecarii]          DATETIME         NULL,
    [MotivIncetareContract] VARCHAR (250)    NULL,
    [Operatie]              SMALLINT         CONSTRAINT [DF_Import_Persoane_Operatie] DEFAULT ((0)) NOT NULL,
    [Selectat]              BIT              CONSTRAINT [DF_Import_Persoane_Selectat] DEFAULT ((1)) NOT NULL,
    CONSTRAINT [PK_Import_Persoane] PRIMARY KEY CLUSTERED ([IdPersoana] ASC) WITH (FILLFACTOR = 90),
    CONSTRAINT [FK_IMPORT_PERSOANE_LOC_NASTERE] FOREIGN KEY ([IDLocNastere]) REFERENCES [dbo].[Localitati] ([IDLocalitate]),
    CONSTRAINT [FK_IMPORT_PERSOANE_LOCALITATI] FOREIGN KEY ([IDLocalitateAdr]) REFERENCES [dbo].[Localitati] ([IDLocalitate]) ON DELETE CASCADE ON UPDATE CASCADE,
    CONSTRAINT [FK_IMPORT_PERSOANE_Localitati_Nastere] FOREIGN KEY ([IDLocNastere]) REFERENCES [dbo].[Localitati] ([IDLocalitate]),
    CONSTRAINT [FK_IMPORT_PERSOANE_Unitati] FOREIGN KEY ([CodUnitate]) REFERENCES [dbo].[Unitati] ([CodUnitate])
);

